package com.cs.study.homework._0228;

import java.awt.image.SampleModel;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class Demo2 {
    public static void main(String[] args) throws ParseException {
        System.out.println("请输入你的出生年月日");
        Scanner sc = new Scanner(System.in);
        String time = sc.nextLine();

        //将字符串转换成日期
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd");
        Date date = dateFormat.parse(time);

        //获取出生日期的毫秒值
        long birth = date.getTime();
        //获取当前时间的毫秒值
        long current = System.currentTimeMillis();
        //将毫秒值转换成天数
        long day = (current - birth) / 1000 / 60 / 60 / 24;

        System.out.println("你来到这个世界" + day + "天了");
    }
}
